﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Owners
{
    public partial class SalesManagerEntities
    {
        public static SalesManagerEntities DefaultContext;

        public string Decrypt(byte[] value)
        {
            var query = CreateQuery<string>("select value SalesManagerModel.Store.Decrypt(@value) from {1}");
            query.Parameters.Add(new System.Data.Objects.ObjectParameter("value", value));
            var result = query.Execute(System.Data.Objects.MergeOption.NoTracking);
            return result.FirstOrDefault();
        }

        public byte[] Encrypt(string value)
        {
            var query = CreateQuery<byte[]>("select value SalesManagerModel.Store.Encrypt(@value) from {1}");
            query.Parameters.Add(new System.Data.Objects.ObjectParameter("value", value));
            var result = query.Execute(System.Data.Objects.MergeOption.NoTracking);
            return result.FirstOrDefault();
        }
    }

    public partial class tblPaymentProcessorConfig
    {
        public string Value1
        {
            get
            {
                if (Value == null)
                    return null;
                else
                    return SalesManagerEntities.DefaultContext.Decrypt(Value);
            }
            set
            {
                OnPropertyChanging("Value1");
                if (value == null)
                    Value = null;
                else
                    Value = SalesManagerEntities.DefaultContext.Encrypt(value);
                OnPropertyChanged("Value1");
            }
        }
    }
}
